home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  3.5 KB  |  128 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPText
  6.     
  7.     SUPERCLASS: CPPVisualObject
  8.     
  9.         This C++ class manages a textedit area, and a horizontal and
  10.         vertical scrollbar which let you adjust the text.
  11.     
  12. ********************************************************************/
  13.  
  14. #pragma once
  15.  
  16. #include <CPPVisualObject.h>
  17.  
  18. class CPPWindow;
  19.  
  20. class CPPText : public CPPVisualObject{
  21. public:
  22.                     CPPText (CPPWindow *OurWindow,
  23.                                   Rect *ViewArea,
  24.                                   Rect *DestArea,
  25.                                   short    maxLength = 32000,
  26.                                   Boolean UseHScroll = TRUE,
  27.                                   Boolean UseVScroll = TRUE,
  28.                                   short Font = geneva, 
  29.                                   short FSize = 9);
  30.                     CPPText (CPPWindow *OurWindow,
  31.                                   short    maxLength = 32000,
  32.                                   Boolean UseHScroll = TRUE,
  33.                                   Boolean UseVScroll = TRUE,
  34.                                   short Font = geneva, 
  35.                                   short FSize = 9);
  36.                     ~CPPText (void);
  37.  
  38.     virtual    char     *ClassName (void);
  39.  
  40.     virtual    Boolean    DoCommand (short commandID);
  41.  
  42.     virtual    void    TypeChar (unsigned char TheKey);
  43.  
  44.     void            DoCut (void);
  45.     void            DoCopy (void);
  46.     virtual    void    DoPaste (void);
  47.     void            DoClear (void);
  48.     void            DoSelectAll (void);
  49.     
  50.             CharsHandle    GetTheText (void);
  51.             short        GetTextLen (void);
  52.     virtual    Boolean    DoKey (char theKey, short modifiers, short what);
  53.     virtual    void    Activate (Boolean nowActive);
  54.     virtual    Boolean DoClick (EventRecord *theEvent);
  55.     virtual    void    DoIdle (void);
  56.     virtual    Rect    *GetBounds (void);
  57.     
  58.     virtual    void    Draw (void);
  59.     virtual    void    MakeVisible (Boolean nowVisible);
  60.     virtual    void    TargetHilite (Boolean makeTarget);
  61.  
  62.     virtual    void     InsertTextPtr (Ptr theText, long textLen, 
  63.                                    long insertWhere, 
  64.                                    Boolean ScrollToInsertion);
  65.             void    InsertTextHandle (Handle theText, long textLen,
  66.                                       long where, 
  67.                                       Boolean ScrollToInsertion);
  68.     virtual    void     SetTextPtr (Ptr theText, long textLen,
  69.                                 Boolean ScrollToInsertion);
  70.             void     SetTextHandle (Handle theText, long textLen,
  71.                                    Boolean ScrollToInsertion);
  72.                                    
  73.     void            SetMinSize (short mwidth, short mheight);
  74.     void            SetMaxSize (short mwidth, short mheight);
  75.  
  76.     void             MoveScrollText (void);
  77.     
  78. protected:
  79.     TEHandle        TextBlock;
  80.     ControlHandle    HScroll;
  81.     ControlHandle     VScroll;
  82.     short            maxTextLen;
  83.  
  84.     virtual    void    ResizeContent (short newWidth, short newHeight);
  85.     virtual    void    MoveContent (short newH, short newV);
  86.  
  87.     void            CheckInsertion (void);
  88.       void            ScrollChar (short charPos, Boolean toBottom);
  89.     
  90. private:
  91.     short            TEminWidth,
  92.                     TEmaxWidth,
  93.                     TEminHeight,
  94.                     TEmaxHeight;
  95.                     
  96.     static    CPPText        *gCurrentTE;
  97.     static    ControlHandle    gVScroll;
  98.     static    ControlHandle    gHScroll;
  99.     static    TEHandle        gTextBlock;
  100.                     
  101.     // static class methods
  102.     static pascal Boolean AutoScroll (void);
  103.     static pascal void Scroll_Right (ControlHandle theControl, 
  104.                                         short ctlPart);
  105.     static pascal void Scroll_Left (ControlHandle theControl, 
  106.                                         short ctlPart);
  107.     static pascal void Scroll_Up (ControlHandle theControl, 
  108.                                         short ctlPart);
  109.     static pascal void Scroll_Down (ControlHandle theControl, 
  110.                                         short ctlPart);
  111.  
  112.     void            MakeTEArea (CPPWindow *OurWindow,
  113.                                 Rect *ViewArea,
  114.                                 Rect *DestArea,
  115.                                 short    maxLength,
  116.                                 Boolean UseHScroll,
  117.                                 Boolean UseVScroll,
  118.                                 short    Font,
  119.                                 short    FSize);
  120.     long             LinesInWindow(void);
  121.     long            LinesInText (void);
  122.     void            VPageScroll (long part, long direction);
  123.     void            HPageScroll (long part, long direction);
  124.     void            AdjustScrollBar (void);
  125.     void             DoVScroller (Point clickPt, short part);
  126.     void            DoHScroller (Point clickPt, short part);
  127.  
  128. };